package com.changpei.search.config;

import com.changpei.search.service.ContentIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 *
 *
 * @author Way on 2021/9/16
 */
@Component
public class Jobs {

    @Autowired
    private ContentIndexService contentIndexService;

    /**
     * 每30分钟执行一次热门数据
     */
    @Scheduled(cron = "0 */30 * * * ?")
    public void refreshHot() {
        System.out.println("更新热门数据，时间为：" + System.currentTimeMillis());
        contentIndexService.hot();
    }

    /**
     * 每10分钟清理一次锁定数据
     */
    @Scheduled(cron = "0 */10 * * * ?")
    public void clearTmpLockData() {
        System.out.println("清理一次锁定数据，时间为：" + System.currentTimeMillis());
        contentIndexService.clearTmpLockData();
    }
}
